class AnimationSheet:
	def __init__(self, img_source, sprite_w, sprite_h, screen, ws):
		self._ws = ws;
		self.img_src = img_source
		self.screen = screen
		self.width = sprite_w
		self.height = sprite_h
		master_width, master_height = self.img_src.get_size()
		self.imgs = []
		for i in xrange(master_width / self.width):
			for j in xrange(master_height / self.height):
				self.imgs.append(self.img_src.subsurface((i*self.width, j*self.height, self.width, self.height)))
				
		
		self.pos = (0,0)
		self.count = len(self.imgs) - 1
		self.cur = 0;
		
		self.img = self.imgs[self.cur]
		
		self.timer_c = 30
		
		self.timer = 0;
	
	def Draw(self):
		self.timer += self._ws.milli
		
		if self.timer > self.timer_c:
			self.timer = self.timer - self.timer_c
			self.cur +=1
			
			if self.cur > self.count:
				self.cur = 0
			self.img = self.imgs[self.cur]
		self.screen.blit(self.img, self.pos)
		
	def SetPos(self, new_pos):
		self.pos = new_pos